var webpack = require("webpack");

//生成HTML
var html = require("html-webpack-plugin");
//删除文件
var clean = require("clean-webpack-plugin");
//压缩代码
var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin;

module.exports = {
    //入口文件
    entry:"./app/app.js",
    output:{//输出地址
        //输出的文件夹名字
        path:__dirname+"/www",
        //输出的js文件名
        filename:"js/bundle.js"
    },
    module:{//模块
        loaders:[
            {   
                //css样式打包
                test:/\.css$/,
                loader:"style-loader!css-loader!less-loader"
            },
            {
                //图片打包
                test:"/\.(png|jpe?g|gif)$/",
                loader:"url-loader?limit=5000s&name=images/[name].[hash:4].[ext]"
            },
            {
                test:/\.vue$/,
                loader:"vue-loader"
            }
        ]
    },
    devServer: {
      contentBase:"./www",
      inline: true,
      port: 8088
    },
    plugins:[
        //生成html
        new html({
            title:"么么哒",
            template:__dirname+"/app/index.html",
            filename:"index.html",
        }),
        //先删除旧的www文件夹,在生成新的www文件夹
        new clean(["www"]),
        //压缩代码
//      new webpack.optimize.UglifyJsPlugin({
//          compress:{
//              warnings:false,//取消报错提示
//          }
//      }),
    ],
    resolve:{
        alias:{
         "vue$": 'vue/dist/vue.common.js',
        }
    }
}